package com.runen.wnhz.runen.ui.adapter.puadapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.runen.wnhz.runen.R;
import com.runen.wnhz.runen.data.entity.MyEvaluationBean;
import com.runen.wnhz.runen.data.entity.MyQuestionBean;
import com.runen.wnhz.runen.ui.activity.mine.AchievementActivity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * NAME：薛世杰
 * DATE：2018/5/2
 * EMIAL：zenhac@163.com
 * DESCRIBE：
 */


public class MyTestListAdapter extends RecyclerView.Adapter<MyTestListAdapter.ViewHodler> {


    private List<MyQuestionBean.DataBean.ListBean> mlist;
    private Context mContext;
    private LayoutInflater inflater;


    public MyTestListAdapter(List<MyQuestionBean.DataBean.ListBean> mlist, Context mContext) {
        this.mlist = mlist;
        this.mContext = mContext;
        inflater = LayoutInflater.from(mContext);
    }

    @Override
    public ViewHodler onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHodler(inflater.inflate(R.layout.my_evluation_record_item,parent,false));
    }

    @Override
    public void onBindViewHolder(ViewHodler holder, final int position) {
        holder.cell_time.setText(mlist.get(position).getLasttime());
        holder.name.setText(mlist.get(position).getTest_name());
        holder.cell_leason.setText("("+mlist.get(position).getLesson_name()+")");
        holder.cell_score.setText(mlist.get(position).getMax_score()+"分");
        holder.my_record_line.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, AchievementActivity.class);
                intent.putExtra("ltid" , mlist.get(position).getTest_id());
                intent.putExtra("mytid",mlist.get(position).getMy_tid());
                intent.putExtra("max_score",mlist.get(position).getMax_score());
                mContext.startActivity(intent);
            }
        });
       /* Glide.with(mContext).load(mlist.get(position).getPic()).into(holder.iv_collection_img);
        holder.tv_collection_title.setText(mlist.get(position).getTitle() +  "标题");
        holder.tv_collection_data.setText("课程有限期：" + mlist.get(position).getExpirytime());
        holder.tv_yikan.setText("已看:" + mlist.get(position).getVcount() + "/" + mlist.get(position).getTcount());
        holder.tv_yidown.setText("已下载:" + mlist.get(position).getDcount() + "/" + mlist.get(position).getTcount());
        holder.linear_lesson_item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, CourseDetailsActivity.class);
                intent.putExtra("lid",mlist.get(position).getLid());
                mContext.startActivity(intent);
            }
        });
*/
    }

    @Override
    public int getItemCount() {
        return mlist.size();
    }

    class ViewHodler extends RecyclerView.ViewHolder{

        @BindView(R.id.test_cell_time)
        TextView cell_time;
        @BindView(R.id.test_cell_name)
        TextView name;
        @BindView(R.id.test_cell_leason)
        TextView cell_leason;
        @BindView(R.id.test_cell_score)
        TextView cell_score;
        @BindView(R.id.my_record_line)
        LinearLayout my_record_line;




        public ViewHodler(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
